package com.vstartek.dm.util;

import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

public class SQLUtil {

	public static String getParams(String[] params) {
		String str = "";
		for (String p : params) {
			if (!p.trim().equals(""))
				str = "," + p + str;
		}
		if (str.length() > 0) {
			str = str.substring(1);
		} else {
			str = "*";
		}
		return str;
	}

	public static void dealTimeWhere(String pama, Query query,PageParam pageParam) {
		boolean fa0 = 	pageParam.isFa0();
		
		boolean fa1 = 	pageParam.isFa1();
		
		if(fa0&&!fa1){
			query.addCriteria(Criteria.where(pama).gte(pageParam.getStartTime()));
		}
		if(fa1&&!fa0){
			query.addCriteria(Criteria.where(pama).lte(pageParam.getEndTime()));
		}
		if(fa0&&fa1){
			query.addCriteria(Criteria.where(pama).lte(pageParam.getEndTime()).gte(pageParam.getStartTime()));
		}
	}

}
